var farms;
farms= new Array();
<% for farms in @farms -%>
  farms.push(new Array(<%= farms.national_id %>, '<%=h farms.farmName %>', <%= farms.id %>));
<% end -%>

function onChange(event){
	var nationalID, farmOption;
    alert('hello');
	nationalID = $('national_id').value;
	farmOption =$('farm_id').options;

	 farmOption.length = 1;
	  farms.each(function(farms) {
	    if (farms[0] == nationalID) {
	      farmOption[farmOption.length] = new Option(farms[1], farms[2]);
	    }
	  });

	if (farmOption.length == 1){
	$('farm_field').hide();
	} else {$('farm_field').show();}
} //end of onChange

function changeName(event){
  var title
  title = "title_test"
  $('product_name').value = title

}//end if changeName

document.observe('dom:loaded', function() {
	//onChange();
	$('national_id').observe('change', onChange);
    $('farm_id').observe('change', changeName);
});



